Related Plugins and Tags

QGIS Planet

QGIS – Modifying a table structure

Modify a table structure

  1. Right click the layer in the Layer’s Panel
  2. Select the Fields tab
  3. It is possible to add/delete columns. It is also possible to change the method of data entry from the default text number cells to specify valid number rangers, selecting pre-set values, tick box, calendar

Updating Fields with Spatial Data

Count within polygons

  • Points: (e.g. levelling points per district). Vector, Analysis tools, Points in Polygon
  • Length :(e.g. road length per district). Vector, Analysis Tools, Sum Line Lengths
  • Area: (e.g. area of land uses per district). Vector, Geo Processing Tools, Union

Calculate Proportional Overlap

  1. Use the Intersect tool to create a new polygon that covers the area of intersection.
  2. Update the area for it and the original regions.
  3. Calculate the area of the new polygon as a % of the area of the original region.

Joining Layers in QGIS

Joining tables allows a layer with the attributes of both source layers to be created. Joins can be based on common attributes or common location (spatial join).

The joined fields are displayed as a new view rather than actually added to the layer. However the join is saved with the project and it will be reloaded each time the project is opened. To permanently add the joined fields to the layer, it must be saved as a new file. To do this, right click on the layer in the Layer Panel and select Save As.

This is because databases are generally designed to be more permanent data repositories than spreadsheets. Therefore their structure shouldn’t be changed for short term projects. Queries can be run and saved without affecting the underlying data.

Join on Common Attributes:-

This method is similar to ArcGIS’ Joins and Relates function. This is done by creating a Vector Join in the layer’s Properties box:-

  1. Right click on the layer in the Layer Panel
  2. Select Properties to open the Properties dialogue box
  3. Select the Join tab
  4. Press the + button to create a new Vector Join:-
Add Vector Join in QGIS

Add Vector Join in QGIS

The Add Vector Join dialogue box opens:-

  • Join Layer – the layer that the join will be to
  • Join Field – the layer in the Join Layer that contains the common attribute
  • Target Field – the field in the currently selected layer that contains the common attribute

Join By Location (Spatial Join)

This function creates a new shapefile containing the geometry of the target layer and the attributes of both layers. The join is based on the Joining layer overlapping or intersecting the target layer:-

  1. Use the menus to select Vector, Data Management Tools; Join Attributes by Location
  2. The Join Attributes by Location box opens, select:-
  • Select the Target vector Layer (the layer to update)
  • Select Join Vector Layer (the layer that will provide the new data)
  • Attribute Summary. This determines the action when a target feature is overlapped by multiple join features:-Take the attributes of the first located feature.
  • Take a summary of intersecting features
  • Output Shapefile – the file that will contain the new data.
Join By Location (Spatial Join) in QGIS

Join By Location (Spatial Join) in QGIS


Updating Attribute Data

Browser Window:

QGIS Browser Window

QGIS Browser Window

Buttons on the bottom from left to right are:-

  • Unselect All
  • Move Selection to Top
  • Invert Selection
  • Copy Selected Rows to Clipboard
  • Zoom Map to the Selected Rows
  • Pan Map to the Selected Rows
  • Toggle Editing
  • Save Edits
  • Delete Selected Features (rows)
  • New Column
  • Delete Column
  • Open Field Calculator
  • Look For (enter search terms) in (use the pull down to select the column to search)

The attribute table has several duplicate rows. To delete them

  1. Press the Toggle Editing to begin an Edit Session
  2. Press the Delete Columns button
  3. Select the column(s) and press OK

To add new columns:

  1. Press the New Column button
  2. Enter the details for the new column
Add column dialog

Add column dialog

Update Columns with the Field Calculator

I want to update the three new columns I’ve added. To update columns:

  1. Right click on the layer in the Layer Panel
  2. Select View Attribute Table
  3. Press the Toggle Editing button to begin an Edit Session
  4. Press the Field Calculator
QGIS Field Calculator

QGIS Field Calculator

  1. Select to either create a new field or to update an existing field. If you’re updating an existing field then use the pull down to select the field
  2. Complete the Expression builder by either double clicking functions or typing the expression.
  3. Functions include:
  • Operators e.g.+-*/ etc
  • Maths e.g. cos, sin etc
  • Conversions e.g. to integer, to string, to decimal
  • Geometry e.g. feature’s length, area, perimeter, x, y
  • Record – Row number or ID
  • Fields and Values

  • Page 1 of 1 ( 3 posts )
  • database design

Back to Top

Sustaining Members